import time

from auto_uitest.ranzhiUitest.caw.basepage import BasePage,getDriver
from producttest.caw.logger import Logger


class LoginPage(BasePage):
    # 将定位设置为属性
    dw_account = "id = account"
    dw_password = "id = password"
    dw_submit = "id = submit"
    dw_qiantui="link text =签退"

    # 登录
    def login(self,user,pwd):
        # 用户名发送数据
        self.send_information(self.dw_account,user)
        self.send_information(self.dw_password,pwd)
        self.click_element(self.dw_submit)
        logger = Logger()
        logger.error(f"-----登录成功------")


    # 退出登录
    def logout(self):
        self.switch_to_default_content()
        self.click_element(self.dw_qiantui)
        logger = Logger()
        logger.error(f"-----退出登录成功------")

if __name__ == '__main__':
    # 获取驱动
    d = getDriver("edge")
    lp = LoginPage(d)
    # 打开页面
    lp.open("http://127.0.0.1/ranzhi/www/")
    # 登录
    lp.login("admin","123456")
    # 退出登录
    lp.logout()
    time.sleep(1)